-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add evm provider and logger #10
Conversation
packages/shared/src/external.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing the export of the Logger class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some small suggestions if you want to address 👍🏻
} | ||
|
||
this.client = createPublicClient({ | ||
chain, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: do we need any validation of the chain? It's completely optional here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should add a validation to ensure that multicall works, thats the only thing that conserns me, just to avoid throwing in the case multicall address doesn't exist. Or maybe providing another way as fallback mechanism like a Promise.all
in case there is no multicall contract (we already talk about the last one with nigiri).
Lets move forward as it is and keep track of this in linear, to tackle the issue in the future.
}); | ||
|
||
describe("getGasPrice", () => { | ||
it("should return the current gas price", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is picky but I think we are supposed to avoid writing "should" for every it() statement and instead just say "returns.."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, will take this to fix during future pr :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice typing. Left two small comments.
* @returns {Promise<bigint>} A Promise that resolves to the latest block number. | ||
*/ | ||
async getBlockNumber(): Promise<bigint> { | ||
return this.client.getBlockNumber(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty convoluted but just wanted to tell that getBlockNumber
by default caches the result by 4 seconds (ie default client's polling interval). [1]
Not sure if this is relevant but might be.
[1] https://viem.sh/docs/actions/public/getBlockNumber.html#cachetime-optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is that relevant, we typically have all the events linked to the blocknumbers where they were emitted
cc @0xnigir1 ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's unlinkely we have an issue with this, its not that we call this method for every event. anyway, lets keep an eye an eventually we set it to 0
async getBlockByNumber(blockNumber: number): Promise<GetBlockReturnType> { | ||
return this.client.getBlock({ blockNumber: BigInt(blockNumber) }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason to use number
over bigint
here? With this interface, someone could pass blockNumber = 5.5
as an argument and BigInt(blockNumber)
would explode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch king
There is a bug in the UI and can't be merged |
Description
chain-providers
shared
test
incheck-types
scriptpricing
testsChecklist before requesting a review